package im.yisme.view.ui.animation;

import im.yisme.view.ui.animation.pojo.ScorePOJO;
import android.util.Log;

public class Score extends Thread{

	private ScorePOJO score;
	private int realScore;
	private static final int POLLING_INTERVAL = 100;
	private static final int UPDATE_INTERVAL = 5;
	private boolean isRunning;
	
	
	public Score(ScorePOJO score){
		this.score = score;
		realScore = 0;
		isRunning = true;
		
	}
	
	public void run(){
		while(isRunning){
			
			try {
				
				if(score.getScore() >= realScore) {
					score.setScore(realScore);
					Thread.sleep(POLLING_INTERVAL);
					continue;
				}
				
				score.setScore(score.getScore() + 5);
				
				Thread.sleep(UPDATE_INTERVAL);
				
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
	}
    public void setRealScore(int realScore){
    	this.realScore = realScore;
	}
    public void stopRunning(){
    	isRunning = false;
    }
}
